//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.andromeda.androbench2;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;

public class ChargingState {
    static final int ERROR = -1;
    static final String UNKNOWN = "unknown";

    public ChargingState() {
    }

    public static int getBatteryLevel(Context var0) {
        Intent var1 = var0.registerReceiver((BroadcastReceiver)null, new IntentFilter("android.intent.action.BATTERY_CHANGED"));
        int var2 = var1.getIntExtra("level", -1);
        int var3 = var1.getIntExtra("scale", -1);
        return var2 != -1 && var3 != -1 ? (int)(100.0D * ((double)var2 / (double)var3)) : -1;
    }

    public static String getChargingState(Context var0) {
        Intent var1 = var0.registerReceiver((BroadcastReceiver)null, new IntentFilter("android.intent.action.BATTERY_CHANGED"));
        int var2 = var1.getIntExtra("status", -1);
        boolean var3;
        if (var2 != 2 && var2 != 5) {
            var3 = false;
        } else {
            var3 = true;
        }

        if (var3) {
            switch(var1.getIntExtra("plugged", -1)) {
                case 1:
                    return "ac";
                case 2:
                    return "usb";
                case 3:
                default:
                    return "unknown";
                case 4:
                    return "wireless";
            }
        } else {
            return "not-charging";
        }
    }
}
